Type.registerNamespace("Telerik.Web");
Type.registerNamespace("Telerik.Web.UI");
(function(){var b=$telerik.$;
var a=Telerik.Web.UI;
b.registerEnum(a,"PaletteModes",{WebPalette:1,RGBSliders:2,HSB:4,HSV:8,All:(1+2+4+8)});
a.ColorPickerColorChangeEventArgs=function(c){a.ColorPickerColorChangeEventArgs.initializeBase(this);
this._oldColor=c;
};
a.ColorPickerColorChangeEventArgs.prototype={get_oldColor:function(){return this._oldColor;
}};
a.ColorPickerColorChangeEventArgs.registerClass("Telerik.Web.UI.ColorPickerColorChangeEventArgs",Sys.EventArgs);
a.ColorPickerColorPreviewEventArgs=function(c){a.ColorPickerColorPreviewEventArgs.initializeBase(this);
this._color=c;
};
a.ColorPickerColorPreviewEventArgs.prototype={get_color:function(){return this._color;
}};
a.ColorPickerColorPreviewEventArgs.registerClass("Telerik.Web.UI.ColorPickerColorPreviewEventArgs",Sys.EventArgs);
a.ColorPickerColorSelectingEventArgs=a.ColorPickerColorPreviewEventArgs;
a.RadColorPicker=function(c){a.RadColorPicker.initializeBase(this,[c]);
this._selectedColor=null;
this._selectedColorName="";
this._autoPostBack=false;
this._enabled=true;
this._previewColor=true;
this._showIcon=false;
this._showEmptyColor=true;
this._lastPreviewColor="";
this._elementsByColor=[];
this._mouseUpHandler=null;
this._localization=null;
this._popupBehavior=null;
this._paletteDisplayed=false;
this._uniqueID=null;
this._columns=18;
this._items=null;
this._width=0;
this._skin="Default";
this._overlay=false;
this._keepInScreenBounds=true;
this._paletteModes=a.PaletteModes.WebPalette;
this._selectedTab=null;
this._selectedContainer=null;
this._tabStrip=null;
this._multiPage=null;
this._webPalettePageView=null;
this._rgbPageView=null;
this._millionColorsPageView=null;
this._rgbSlidersDefaultValue=255;
this._rgbSlidersDefaultSize=232;
this._redInput=null;
this._greenInput=null;
this._blueInput=null;
this._hexColorInput=null;
this._applyButton=null;
this._defaultRGBWidth=300;
this._rgbSlidersMinSize=118;
this._eventStartedInControl=false;
this._inputAvoidRecursion=false;
this._sliderAvoidRecursion=false;
this._millionColorsPalette=null;
this._millionColorsHandle=null;
this._millionColorsSliderWidth="22px";
this._millionColorsSliderHeight="258px";
this._defaultMillionColorsWidth=350;
this._millionColorsInputs=null;
this._millionColorsAvoidRecursion=false;
this._millionColorsSliderAvoidRecursion=false;
this._footer=null;
this._rightToLeft=false;
this._paletteSizes={};
this.ShowPalette=this.showPalette;
this.HidePalette=this.hidePalette;
this.GetIconContainer=this.getIconContainer;
this.GetPaletteContainer=this.getPaletteContainer;
};
a.RadColorPicker.prototype={initialize:function(){a.RadColorPicker.callBaseMethod(this,"initialize");
var c=this.get_element();
if($telerik.isRightToLeft(c)){Sys.UI.DomElement.addCssClass(c,"RadColorPickerRTL");
Sys.UI.DomElement.addCssClass(c,"RadColorPickerRTL_"+this._skin);
this._rightToLeft=true;
}this._initializeFields();
this._localization=eval(this._localization);
if(!this._showIcon){this._paletteDisplayed=true;
this._initializeColorElementsArray();
this._setElementsSize();
}this._initializeEventHandlers();
this.set_selectedColor(this._selectedColor);
if(this._items){this._items=eval(this._items);
}this.raiseEvent("load");
},_initializeFields:function(){var l=this.get_id();
this._wrapperElement=$get(l);
this._previewElement=$get(l+"_preview");
this._emptyColorElement=$get(l+"_emptycolor");
this._iconElement=$get(l+"_icon");
this._iconWrapperElement=$get(l+"_label");
var j=this._paletteWrapperElement=$get(l+"_palette");
if(j){var c=this._tabStrip=$telerik.getChildByClassName(j,"rcpTabs");
this._multiPage=$telerik.getChildByClassName(j,"rcpViews");
var k=this._footer=$telerik.getChildByClassName(j,"rcpFooter");
var e=this._webPalettePageView=$get(l+"_webPalette");
this._webPaletteWrapper=(e)?$telerik.getChildByClassName(e,"rcpWebPalette"):null;
var n=this._rgbPageView=$get(l+"_rgbSliders");
this._millionColorsPageView=$get(l+"_millionColors");
this._selectedContainer=(e)?e:(n?n:this._millionColorsPageView);
if(c){var f=c.getElementsByTagName("a");
for(var m=0,h=f.length;
m<h;
m++){this._initializeTabHandler(f[m]);
}this._selectedTab=$telerik.getElementByClassName(c,"rcpSelectedTab","li");
}if(k){var o=this._applyButton=$telerik.getChildByClassName(k,"rcpApplyButton");
this._initializeApplyHandler(o);
}}this._redInput=$get(l+"_redInput");
this._greenInput=$get(l+"_greenInput");
this._blueInput=$get(l+"_blueInput");
var d=this._hexColorInput=$get(l+"_hexInput");
if(this.get_redSlider()){this._initializeRgbInputHandler(this._redInput);
this._initializeRgbInputHandler(this._greenInput);
this._initializeRgbInputHandler(this._blueInput);
this._initializeRgbSliderHandler(this.get_redSlider());
this._initializeRgbSliderHandler(this.get_greenSlider());
this._initializeRgbSliderHandler(this.get_blueSlider());
}if(d){this._initializeHexHandler(d);
}this._millionColorsPalette=$get(l+"_millionColorsPalette");
this._initializeMillionColorsPaletteHandler();
this._millionColorsHandle=$get(l+"_millionColorsHandle");
this._createHandleResizeExtender();
this._initializeMillionColorsSliderHandler();
var g=this._millionColorsInputs={r:$get(l+"_rInput"),g:$get(l+"_gInput"),b:$get(l+"_bInput"),h:$get(l+"_hInput"),s:$get(l+"_sInput"),l:$get(l+"_lInput"),v:$get(l+"_vInput")};
this._initializeMillionColorsRgbInputHandler(g.r);
this._initializeMillionColorsRgbInputHandler(g.g);
this._initializeMillionColorsRgbInputHandler(g.b);
this._initializeMillionColorsInputHandler(g.h);
this._initializeMillionColorsInputHandler(g.s);
this._initializeMillionColorsInputHandler(g.l);
this._initializeMillionColorsInputHandler(g.v);
},dispose:function(){this._disposeControl("_popupBehavior");
this._disposeHandlers();
this._selectedTab=null;
this._selectedContainer=null;
var c=this._tabStrip;
if(c){var e=c.getElementsByTagName("a");
for(var g=0,f=e.length;
g<f;
g++){$clearHandlers(e[g]);
}}this._tabStrip=null;
this._multiPage=null;
this._webPaletteWrapper=null;
this._webPalettePageView=null;
this._rgbPageView=null;
this._millionColorsPageView=null;
this.set_redSlider(null);
this.set_greenSlider(null);
this.set_blueSlider(null);
this.set_hiddenSlider(null);
this._clearHandlers("_redInput");
this._clearHandlers("_greenInput");
this._clearHandlers("_blueInput");
this._clearHandlers("_hexColorInput");
this._clearHandlers("_applyButton");
this._millionColorsPalette=null;
this._millionColorsHandle=null;
this.set_millionColorsSlider(null);
var d=this._millionColorsInputs;
this._clearHandlers(null,d.r);
this._clearHandlers(null,d.g);
this._clearHandlers(null,d.b);
this._clearHandlers(null,d.h);
this._clearHandlers(null,d.s);
this._clearHandlers(null,d.l);
this._clearHandlers(null,d.v);
this._millionColorsInputs=null;
this._footer=null;
this._paletteSizes=null;
a.RadColorPicker.callBaseMethod(this,"dispose");
},_disposeControl:function(d){var c=this[d];
if(c){c.dispose();
this[d]=null;
}},_clearHandlers:function(f,c){var d=(!c);
var e=d?this[f]:c;
if(e){$clearHandlers(e);
if(d){this[f]=null;
}}},_initializeColorElementsArray:function(){var e=this._webPaletteWrapper;
if(!e){return;
}var h=[];
var f=e.getElementsByTagName("a");
for(var g=0,d=f.length;
g<d;
g++){var c=f[g];
if(this._getColorBoxElement(c)==null){continue;
}h[this._getElementColor(c)]=c;
}this._elementsByColor=h;
},_setElementsSize:function(){var j=this._selectedContainer;
var c=a.PaletteModes.WebPalette;
var i="_setWebPaletteSize";
if(j==this._rgbPageView){c=a.PaletteModes.RGBSliders;
i="_setRGBSize";
}else{if(j==this._millionColorsPageView){c=(a.PaletteModes.HSB+a.PaletteModes.HSV);
i="_setMillionColorsSize";
}}var g=this._showIcon?this._paletteWrapperElement:this._wrapperElement;
if(!g){return;
}var d=this._getElementsSize(c);
var e=d.width;
if(parseInt(g.style.width)!=e){g.style.width=(e-this.getElementBox(g).horizontal)+"px";
}if(e<203&&this._previewColor){var h=this._emptyColorElement;
if(h){var f=$telerik.getFirstChildByTagName(h,"span");
if(f){f.style.display="none";
}h.style.width="23px";
}}this[i](d);
},_setWebPaletteSize:function(d){var c=this._webPaletteWrapper;
if(!c){return;
}if(this.isModeEnabled(a.PaletteModes.WebPalette)){var j=d.colorBoxSize;
var g=$telerik.isOpera;
var h=d.colorBoxSizeOpera;
var f=c.getElementsByTagName("li");
for(var m=0,l=f.length;
m<l;
m++){var n=f[m];
var e=n.getElementsByTagName("span");
if(e.length>0){var k=e[0];
if(parseInt(k.style.width)!=j){k.style.width=j+"px";
k.style.height=j+"px";
}}if(g){n.style.width=h+"px";
}}}},_setRGBSize:function(c){var d=c.sliderSize;
this.get_redSlider().set_width(d);
this.get_greenSlider().set_width(d);
this.get_blueSlider().set_width(d);
},_setMillionColorsSize:function(c){},_getElementsSize:function(c){var i=this._paletteSizes;
var d=this._width;
var m=(d>0);
var n=this._wrapperElement;
var l=0;
if(!this._showIcon){l+=this.getElementBox(n).horizontal;
this._rgbSlidersDefaultSize-=l;
}l+=this.getElementBox(this._paletteWrapperElement).horizontal;
l+=this.getElementBox(this._multiPage).horizontal;
var j,f,h;
if(this.isModeEnabled(a.PaletteModes.WebPalette)&&(c==a.PaletteModes.WebPalette)){var k=this._getWebPaletteElemenentsSize(d,l);
j=k.colorSize;
f=k.colorSizeOpera;
d=k.width;
i.webPalette=d;
}else{if(this.isModeEnabled(a.PaletteModes.RGBSliders)&&(c==a.PaletteModes.RGBSliders)){var o=this._defaultRGBWidth;
var g=this._rgbSlidersMinSize;
if(!m){d=o;
}else{if(d<g){d=g;
}}i.rgbSliders=d;
h=this._getRGBElemenentsSize(d,l);
}else{if((this.isModeEnabled(a.PaletteModes.HSB)&&(c&a.PaletteModes.HSB))||(this.isModeEnabled(a.PaletteModes.HSV)&&(c&a.PaletteModes.HSV))){var e=this._defaultMillionColorsWidth;
if(!m||(m&&d<e)){d=e;
}i.millionColors=d;
}}}this._paletteSizes=i;
return{colorBoxSize:j,colorBoxSizeOpera:f,sliderSize:h,width:d};
},_getWebPaletteElemenentsSize:function(e,l){l+=this.getElementBox(this._webPalettePageView).horizontal;
var c=0;
var f=0;
var k=this._webPaletteWrapper;
if(k){l+=this.getElementBox(k).horizontal;
l+=$telerik.getMarginBox(k).horizontal;
var n=$telerik.getFirstChildByTagName(k,"li");
if(n){f=$telerik.getOuterSize(n).width;
c+=this.getElementBox(n).horizontal;
var h=$telerik.getFirstChildByTagName(n,"a");
if(h){c+=this.getElementBox(h).horizontal;
var d=$telerik.getFirstChildByTagName(h,"span");
c+=this.getElementBox(d).horizontal;
}}}var j=this._columns;
if(e>0){var i=e-l;
i=(i<1)?1:i;
f=parseInt(i/j);
f=(f<1)?1:f;
}else{e=l+j*f;
}var g=f;
var m=f-c;
m=(m<1)?1:m;
return{colorSize:m,colorSizeOpera:g,width:e};
},_getRGBElemenentsSize:function(d,f){var g=this._rgbSlidersDefaultSize;
var c=this._defaultRGBWidth;
if(d!=c){var h=this._redInput;
var e=$telerik.getChildrenByTagName(h.parentNode,"label")[0];
f+=this.getElementBox(this._rgbPageView).horizontal;
g=d-f;
g-=$telerik.getOuterSize(h).width;
g-=$telerik.getOuterSize(e).width;
if(g<50){g=50;
}}return g;
},_createPalette:function(g){if(this._webPaletteWrapper){return;
}var h=this._webPaletteWrapper=this._createElement("ul",null,{className:"rcpWebPalette"});
g.appendChild(h);
var e=0;
var k=this._columns;
var d=this._items;
for(var c=0,f=d.length;
c<f;
c++){if(e==k){e=0;
var j=this._createElement("li",null,{className:"rcpBreakLine"});
h.appendChild(j);
}e++;
var l=this._createColorElement(d[c]);
h.appendChild(l);
}this._setElementsSize();
},_createColorElement:function(g){var c=(this._selectedColor==g.value)?"rcpSelectedColor":"rcpColorBox";
var e=this._createElement("li");
var d=this._createA(g.title,c,null,g.value);
var f=this._createElement("span",g.value);
d.appendChild(f);
e.appendChild(d);
return e;
},_createHeader:function(c){if(!this._previewColor&&!this._showEmptyColor){return;
}var d=this._createDiv("rcpHeader");
c.appendChild(d);
this._createPreviewElement(d);
this._createEmptyColorElement(d);
},_createFooter:function(){if(this._footer){return;
}var e=this._footer=this._createDiv("rcpFooter");
this._paletteWrapperElement.appendChild(e);
var d=this._applyButton=this._createA(null,"rcpApplyButton");
e.appendChild(d);
this._initializeApplyHandler(d);
var c=this._createElement("span",this._localization[7]);
d.appendChild(c);
},_createRgbSliders:function(f){if(this.get_redSlider()){return;
}var g=this._createElement("ul");
f.appendChild(g);
var c=this.get_id();
var d=c+"_redSlider";
var e=c+"_redInput";
this._createRgbSliderWithInput(d,"rcpSlider rcpRedSlider","_redSlider",e,"rcpInput rcpRedInput","_redInput","R:",g);
d=c+"_greenSlider";
e=c+"_greenInput";
this._createRgbSliderWithInput(d,"rcpSlider rcpGreenSlider","_greenSlider",e,"rcpInput rcpGreenInput","_greenInput","G:",g);
d=c+"_blueSlider";
e=c+"_blueInput";
this._createRgbSliderWithInput(d,"rcpSlider rcpBlueSlider","_blueSlider",e,"rcpInput rcpBlueInput","_blueInput","B:",g);
this._createFooter();
this._setElementsSize();
this._updateRgbSlidersUI(this._getRgbFromHex());
},_createRgbSliderWithInput:function(j,h,e,n,i,g,k,m){var c=this._createElement("li");
m.appendChild(c);
var l=this._createElement("label",k,{htmlFor:n});
c.appendChild(l);
var d=this._createInput(i,this._rgbSlidersDefaultValue,n);
c.appendChild(d);
this._initializeRgbInputHandler(d);
this[g]=d;
var f=this._createDiv(h,j);
c.appendChild(f);
this[e]=this._createSlider(f);
},_createSlider:function(e){var d=this._rgbSlidersDefaultValue;
var c=this._rgbSlidersDefaultSize+"px";
var f={itemData:[],_width:c,_skin:this._skin,maximumValue:d,value:d,_increaseText:this._localization[8],_decreaseText:this._localization[9],_dragText:this._localization[10]};
var g=$create(a.RadSlider,f,null,null,e);
this._initializeRgbSliderHandler(g);
return g;
},_rgbValuesToHex:function(d,e,f){var g="#";
var c=function(i){var h=parseInt(i,10).toString(16);
g=g+(h.length==1?"0"+h:h);
};
c(d);
c(e);
c(f);
c=null;
return g;
},_createHexColorInput:function(e){var f=this._selectedColor;
if(!f){var c=this._rgbSlidersDefaultValue;
f=this._rgbValuesToHex(c,c,c);
}var d=this._hexColorInput=this._createInput("rcpHexInput",f);
e.appendChild(d);
if(this.isModeEnabled(a.PaletteModes.WebPalette)){d.readOnly="readonly";
}this._initializeHexHandler(d);
},_createMillionColors:function(k){if(this.get_millionColorsSlider()){return;
}var i=this.get_id();
var d=this._createDiv("rcpInputsWrapper");
k.appendChild(d);
var f=this._createElement("ul");
d.appendChild(f);
this._createListItemWithInput((i+"_rInput"),"rcpInput rcpRedInput","r","R:","_initializeMillionColorsRgbInputHandler",f);
this._createListItemWithInput((i+"_gInput"),"rcpInput rcpGreenInput","g","G:","_initializeMillionColorsRgbInputHandler",f);
this._createListItemWithInput((i+"_bInput"),"rcpInput rcpBlueInput","b","B:","_initializeMillionColorsRgbInputHandler",f);
f=this._createElement("ul",null,{className:"rcpMillionColorsInputs"});
d.appendChild(f);
this._createListItemWithInput((i+"_hInput"),"rcpInput rcpHInput","h","H:","_initializeMillionColorsInputHandler",f);
this._createListItemWithInput((i+"_sInput"),"rcpInput rcpSInput","s","S:","_initializeMillionColorsInputHandler",f);
if(this.isModeEnabled(a.PaletteModes.HSB)){this._createListItemWithInput((i+"_lInput"),"rcpInput rcpLInput","l","B:","_initializeMillionColorsInputHandler",f,"rcpLInputWrapper");
}if(this.isModeEnabled(a.PaletteModes.HSV)){this._createListItemWithInput((i+"_vInput"),"rcpInput rcpVInput","v","V:","_initializeMillionColorsInputHandler",f,"rcpVInputWrapper");
}var g=this._millionColorsPalette=this._createDiv("rcpMillionColorsPalette",(i+"_millionColorsPalette"));
k.appendChild(g);
this._initializeMillionColorsPaletteHandler();
var h=this._millionColorsHandle=this._createElement("div","<!-- / -->",{className:"rcpMillionColorsHandle"},{top:"0px",left:"0px"});
g.appendChild(h);
this._createHandleResizeExtender();
var l=this._createDiv("rcpMillionColorsSlider",(i+"_millionColorsSlider"));
k.appendChild(l);
var e=this._isModeSelected(a.PaletteModes.HSB)?this._localization[11]:this._localization[12];
var j=0;
var c={itemData:[],_height:this._millionColorsSliderHeight,_width:this._millionColorsSliderWidth,_skin:this._skin,maximumValue:100,value:j,orientation:1,showIncreaseHandle:false,showDecreaseHandle:false,_dragText:e};
this.set_millionColorsSlider($create(a.RadSlider,c,null,null,l));
this._initializeMillionColorsSliderHandler();
this._createFooter();
this._setElementsSize();
},_createListItemWithInput:function(l,h,f,j,e,k,d){var c=this._createElement("li",null,{className:d});
k.appendChild(c);
var i=this._createElement("label",j,{htmlFor:l});
c.appendChild(i);
var g=this._createInput(h,0,l);
c.appendChild(g);
this[e](g);
this._millionColorsInputs[f]=g;
},_createHandleResizeExtender:function(){var f=this._millionColorsHandle;
if(!f){return;
}var e="default";
var c={};
c[e]=f;
var d=new a.ResizeExtender(this,f,c,null,null,e,false);
},_rgbSliderValueChanged:function(c,d){if(this._sliderAvoidRecursion){return;
}var g=this.get_redSlider().get_value();
var e=this.get_greenSlider().get_value();
var f=this.get_blueSlider().get_value();
this._sliderAvoidRecursion=true;
this._updateHexPreview(g,e,f);
this._updateRgbInputUI(c);
this._sliderAvoidRecursion=false;
},_millionColorsSliderValueChanged:function(c,d){if(this._sliderAvoidRecursion||this._millionColorsSliderAvoidRecursion){return;
}var e=this._getMillionColorsCoordinates();
this._sliderAvoidRecursion=true;
this._updateMillionColorsInputsUI(e.x,e.y);
this._sliderAvoidRecursion=false;
},_hexColorChange:function(h){if(!h){return;
}if(this._isModeSelected(a.PaletteModes.WebPalette)){return;
}var d=h.target||h.srcElement;
if(!this._validateHexInput(d)){this._previewCurrentColor(this._selectedColor);
return;
}if(this._inputAvoidRecursion){return;
}if(this._selectedContainer){var c=d.value;
var g=this._getRgbFromHex(c);
var f=this._isModeSelected(a.PaletteModes.RGBSliders)?"_updateRgbSlidersUI":(this._isModeSelected(a.PaletteModes.HSB)?"_updateHslPaletteElementsUI":"_updateHsvPaletteElementsUI");
this._inputAvoidRecursion=true;
this[f](g);
this._inputAvoidRecursion=false;
}},_rgbInputValueChange:function(g){if(!g){return;
}var c=g.target||g.srcElement;
if(!this._validateDecInput(c,0,255)){c.value=this._getSliderFromInput(c).get_value();
return;
}if(this._inputAvoidRecursion){return;
}var h=parseInt(this._redInput.value);
var d=parseInt(this._greenInput.value);
var f=parseInt(this._blueInput.value);
this._inputAvoidRecursion=true;
this._updateHexPreview(h,d,f);
this._updateRgbSliderUI(null,null,c);
this._inputAvoidRecursion=false;
},_millionColorsInputValueChange:function(i){if(!i){return;
}var f=i.target||i.srcElement;
var c=this._isMillionColorsTabSelected().HSB;
var g=this._millionColorsInputs;
var d=(f.id==g.h.id)?360:100;
if(!this._validateDecInput(f,0,d)){var j=c?"_resetHslInputValue":"_resetHsvInputValue";
this[j](f);
return;
}if(this._inputAvoidRecursion){return;
}var l=c?"_updateHslPaletteElementsUI":"_updateHsvPaletteElementsUI";
var h=parseInt(g.h.value);
var k={h:((h==360)?0:h),s:parseInt(g.s.value)/100,l:(g.l?parseInt(g.l.value)/100:null),v:(g.v?parseInt(g.v.value)/100:null),hueValue:h};
this._inputAvoidRecursion=true;
this[l](null,k);
this._inputAvoidRecursion=false;
},_millionColorsRgbInputValueChange:function(g){if(!g){return;
}var c=g.target||g.srcElement;
if(!this._validateDecInput(c,0,255)){this._resetRgbInputValue(c);
return;
}if(this._inputAvoidRecursion){return;
}if(this._selectedContainer){var d=this._millionColorsInputs;
var f={r:parseInt(d.r.value),g:parseInt(d.g.value),b:parseInt(d.b.value)};
var h=this._isMillionColorsTabSelected().HSB?"_updateHslPaletteElementsUI":"_updateHsvPaletteElementsUI";
this._inputAvoidRecursion=true;
this[h](f);
this._inputAvoidRecursion=false;
}},_onMillionColorsPaletteMouseDown:function(i){if(!this._enabled){return;
}if(this._millionColorsAvoidRecursion){return;
}var f=this._millionColorsPalette;
var d=$telerik.getLocation(f);
var g=$telerik.getBorderBox(f);
var c=$telerik.getDocumentRelativeCursorPosition(i);
var j=c.left-d.x-g.left;
var h=c.top-d.y-g.top;
j=this._fixInRgbRange(j,true);
h=this._fixInRgbRange(h,true);
this._updateMillionColorsHandleUI(j,h);
this._millionColorsAvoidRecursion=true;
this._updateMillionColorsInputsUI(j,h);
this._millionColorsAvoidRecursion=false;
},onDragStart:function(d){if(!this._enabled){return false;
}var h=d.element;
var c=this._cachedMillionColorsHandleSize=$telerik.getSize(h);
var e=Math.floor(c.width/2);
var f=Math.floor(c.height/2);
var g=$telerik.getContentSize(this._millionColorsPalette);
this._cachedMillionColorsPaletteBounds=new Sys.UI.Bounds(-e,-f,(g.width+e*2),(g.height+f*2));
this._eventStartedInControl=true;
return true;
},onDragEnd:function(d){var e=d.element;
var c=this._cachedMillionColorsHandleSize;
this._updateMillionColorsInputsUI(parseInt(e.style.left)+Math.floor(c.width/2),parseInt(e.style.top)+Math.floor(c.height/2));
this._cachedMillionColorsHandleSize=null;
this._cachedMillionColorsPaletteBounds=null;
},onDrag:function(d){var c=this._cachedMillionColorsHandleSize;
var f=this._cachedMillionColorsPaletteBounds;
if(f.width<1||f.height<1){return false;
}d.width=c.width;
d.height=c.height;
var e=a.ResizeExtender.containsBounds(f,d);
if(!e){if(d.x<=f.x){d.x=f.x;
}else{if(f.x+f.width<=d.x+c.width){d.x=f.x+f.width-c.width;
}}if(d.y<=f.y){d.y=f.y;
}else{if(f.y+f.height<=d.y+c.height){d.y=f.y+f.height-c.height;
}}e=true;
}if(e){this._updateMillionColorsInputsUI(d.x+Math.floor(c.width/2),d.y+Math.floor(c.height/2));
}return e;
},_updateRgbSlidersUI:function(c){if(!c){return;
}this._updateRgbSliderUI(this.get_redSlider(),c.r);
this._updateRgbSliderUI(this.get_greenSlider(),c.g);
this._updateRgbSliderUI(this.get_blueSlider(),c.b);
},_updateRgbSliderUI:function(f,c,d){var g=f;
var e=c;
if(!g){if(!d){return;
}g=this._getSliderFromInput(d);
e=parseInt(d.value);
}g.set_value(e);
},_updateRgbInputUI:function(c){if(!c){return;
}this._getInputFromSlider(c).value=c.get_value();
},_updateMillionColorsHandleUI:function(f,e){var d=this._millionColorsHandle;
var c=$telerik.getSize(d);
$telerik.setLocation(d,{x:f-Math.floor(c.width/2),y:e-Math.floor(c.height/2)});
},_updateMillionColorsInputsUI:function(h,f){if(this._inputAvoidRecursion){return;
}var d=this._isMillionColorsTabSelected();
var c=d.HSB;
if(!c&&!d.HSV){return;
}var g=this[c?"_getHslFromCoordinates":"_getHsvFromCoordinates"](h,f);
var e=this[c?"_hslToRgb":"_hsvToRgb"](g.h,g.s,g[c?"l":"v"]);
this[c?"_updateHslSliderBackground":"_updateHsvPaletteBackground"](g);
this._updateMillionColorsInputsValues(e,g);
this._updateHexPreview(e.r,e.g,e.b);
},_updateMillionColorsInputsValues:function(e,d){var c=this._millionColorsInputs;
if(e){c.r.value=e.r;
c.g.value=e.g;
c.b.value=e.b;
}c.h.value=Math.round(d.hueValue);
c.s.value=Math.round(d.s*100);
if(d.l!=null){c.l.value=Math.round(d.l*100);
}if(d.v!=null){c.v.value=Math.round(d.v*100);
}},_updateHslPaletteElementsUI:function(f,e){if(!f&&!e){return;
}var d=(f)?f:this._hslToRgb(e.h,e.s,e.l);
var c=(e)?e:this._rgbToHsl(f);
this._updateHexPreview(d.r,d.g,d.b);
this._updateMillionColorsInputsValues(d,c);
this._updateHslSliderBackground(c);
this._updateMillionColorsHandleUI(Math.round(c.h*255/360),255-Math.round(c.s*255));
this.get_millionColorsSlider().set_value(100-Math.round(c.l*100));
},_updateHslSliderBackground:function(c){var d=this._hslToRgb(c.h,c.s,0.5);
this.get_millionColorsSlider()._trackElement.style.backgroundColor=this._rgbValuesToHex(d.r,d.g,d.b);
},_updateHsvPaletteElementsUI:function(f,c){if(!f&&!c){return;
}var e=(f)?f:this._hsvToRgb(c.h,c.s,c.v);
var d=(c)?c:this._rgbToHsv(f);
this._updateHexPreview(e.r,e.g,e.b);
this._updateMillionColorsInputsValues(e,d);
this._updateHsvPaletteBackground(d);
this._updateMillionColorsHandleUI(Math.round(d.s*255),255-Math.round(d.v*255));
this.get_millionColorsSlider().set_value(100-Math.round(d.h*100/360));
},_updateHsvPaletteBackground:function(c){var d=this._hsvToRgb(c.h,1,1);
this._millionColorsPalette.style.backgroundColor=this._rgbValuesToHex(d.r,d.g,d.b);
},_updateHexPreview:function(e,f,d){var c=this._rgbValuesToHex(e,f,d);
this._previewCurrentColor(c,true);
},_getRgbFromHex:function(f){var e=f;
if(!e){var d=this._rgbSlidersDefaultValue;
var c=this._selectedColor;
e=(c)?c:"#FFFFFF";
}return this._hexToRgb(e);
},_resetRgbInputValue:function(e){var f;
var g=this._hexColorInput;
if(g){f=this._getRgbFromHex(g.value);
}else{var h=this._getMillionColorsCoordinates();
if(this._isModeSelected(a.PaletteModes.HSB)){var d=this._getHslFromCoordinates(h.x,h.y);
rgb=this._hslToRgb(d.h,d.s,d.l);
}else{if(this._isModeSelected(a.PaletteModes.HSV)){var c=this._getHsvFromCoordinates(h.x,h.y);
rgb=this._hsvToRgb(c.h,c.s,c.v);
}}}var i=this._millionColorsInputs;
e.value=(e===i.r)?f.r:(e===i.g?f.r:f.b);
},_resetHslInputValue:function(c){var e=this._getMillionColorsCoordinates();
var d=this._getHslFromCoordinates(e.x,e.y);
this._updateMillionColorsInputsValues(null,d);
},_resetHsvInputValue:function(d){var e=this._getMillionColorsCoordinates();
var c=this._getHsvFromCoordinates(e.x,e.y);
this._updateMillionColorsInputsValues(null,c);
},_validateDecInput:function(e,c,g){var d=parseInt(e.value);
var f=(!isNaN(d));
if(f){f=(d>=c&&d<=g);
}return f;
},_validateHexInput:function(c){var d=c.value;
var e=/^#?(([0-9a-f]{3})|([0-9a-f]{6}))$/i;
return e.test(d);
},_getSliderFromInput:function(c){var d=this._getColorElementPrefix(c.id.toLowerCase());
return this[d+"Slider"];
},_getInputFromSlider:function(d){var c=this._getColorElementPrefix(d.get_id().toLowerCase());
return this[c+"Input"];
},_getColorElementPrefix:function(d){var c="";
if(!d){return c;
}if(d.indexOf("red")>-1){c="_red";
}else{if(d.indexOf("green")>-1){c="_green";
}else{if(d.indexOf("blue")>-1){c="_blue";
}}}return c;
},_getMillionColorsCoordinates:function(){var f=this._millionColorsHandle;
if(!f){return{x:0,y:0};
}var c=$telerik.getSize(f);
var d=parseInt(f.style.left)+Math.floor(c.width/2);
var e=parseInt(f.style.top)+Math.floor(c.height/2);
return{x:d,y:e};
},_getHslFromCoordinates:function(h,g){var e=(h/255*360);
var c=(h==255)?0:e;
var f=1-g/255;
var d=1-(this.get_millionColorsSlider().get_value()/100);
return{h:c,s:f,l:d,hueValue:e};
},_getHsvFromCoordinates:function(i,h){var g=this.get_millionColorsSlider().get_value();
var f=360*(1-g/100);
var e=(g==0)?0:f;
var c=i/255;
var d=1-h/255;
return{h:e,s:c,v:d,hueValue:f};
},_hexToRgb:function(e){if(!e){return null;
}var c={r:0,g:0,b:0};
if(e.indexOf("#")!=-1){e=e.substring(1,e.length);
}if(e.length==3){var d=function(f){return(f+f);
};
e=e.replace(/([0-9a-f])/gi,d);
}c.r=parseInt(e.substring(0,2),16);
c.g=parseInt(e.substring(2,4),16);
c.b=parseInt(e.substring(4,6),16);
return c;
},_hslToRgb:function(c,d,g){var f=this._hueToRgb(c);
f=this._addRgbVectors(this._multiplyRgbVectorByNum(d,f),this._multiplyRgbVectorByNum((1-d),{r:128,g:128,b:128}));
if(g!=0.5){var e=(g<0.5)?{r:0,g:0,b:0}:{r:255,g:255,b:255};
var h=2*Math.abs(0.5-g);
f=this._addRgbVectors(this._multiplyRgbVectorByNum(h,e),this._multiplyRgbVectorByNum((1-h),f));
}return f;
},_hsvToRgb:function(d,e,c){var f={r:0,g:0,b:0};
if(e==0){f={r:c,g:c,b:c};
}else{var h=(1-e)*c;
var g=c*e*(d%60)/60;
if(d<60){f={r:c,g:(h+g),b:h};
}else{if(d<120){f={r:c-g,g:c,b:h};
}else{if(d<180){f={r:h,g:c,b:h+g};
}else{if(d<240){f={r:h,g:c-g,b:c};
}else{if(d<300){f={r:h+g,g:h,b:c};
}else{if(d<360){f={r:c,g:h,b:c-g};
}}}}}}}return this._multiplyRgbVectorByNum(255,f);
},_hueToRgb:function(c){var d={};
var e=c/60;
var f=e-Math.floor(e);
if(e<1){d={r:1,g:f,b:0};
}else{if(e<2){d={r:(1-f),g:1,b:0};
}else{if(e<3){d={r:0,g:1,b:f};
}else{if(e<4){d={r:0,g:(1-f),b:1};
}else{if(e<5){d={r:f,g:0,b:1};
}else{d={r:1,g:0,b:(1-f)};
}}}}}return this._multiplyRgbVectorByNum(255,d);
},_rgbToHsl:function(f){var e={};
var d=Math.min(Math.min(f.r,f.g),f.b);
var g=Math.max(Math.max(f.r,f.g),f.b);
var c=(g+d);
var h=g-d;
e.l=c/(2*255);
if(h==0){e.h=0;
e.s=0;
}else{e.s=h/((e.l<=0.5)?c:(2*255-c));
e.h=this._rgbToHue(f,h);
}e.hueValue=e.h;
return e;
},_rgbToHsv:function(e){var c={};
var f=Math.max(Math.max(e.r,e.g),e.b);
var d=Math.min(Math.min(e.r,e.g),e.b);
var g=f-d;
c.v=(f/255);
if(g==0){c.h=0;
c.s=0;
}else{c.s=(g/f);
c.h=this._rgbToHue(e,g);
}c.hueValue=c.h;
return c;
},_rgbToHue:function(e,d){var c=0;
if(e.r>=e.g&&e.g>=e.b){c=60*(e.g-e.b)/d;
}else{if(e.g>=e.r&&e.r>=e.b){c=60+60*(e.g-e.r)/d;
}else{if(e.g>=e.b&&e.b>=e.r){c=120+60*(e.b-e.r)/d;
}else{if(e.b>=e.g&&e.g>=e.r){c=180+60*(e.b-e.g)/d;
}else{if(e.b>=e.r&&e.r>=e.g){c=240+60*(e.r-e.g)/d;
}else{if(e.r>=e.b&&e.b>=e.g){c=300+60*(e.r-e.b)/d;
}}}}}}return Math.round(c);
},_isModeSelected:function(g,c,h){var e=false;
var f=c?c:this._selectedContainer;
if(f){if(g==a.PaletteModes.WebPalette){e=(this._webPalettePageView===f);
}else{if(g==a.PaletteModes.RGBSliders){e=(this._rgbPageView===f);
}else{var d=this._isMillionColorsTabSelected(h);
e=(g==a.PaletteModes.HSB)?d.HSB:d.HSV;
}}}return e;
},_isMillionColorsTabSelected:function(e){var c=e;
if(!c){c=this._selectedTab;
}if(c){var d=c.getElementsByTagName("span")[0].innerHTML;
return{HSB:(d==this._localization[5]),HSV:(d==this._localization[6])};
}else{return{HSB:this.isModeEnabled(a.PaletteModes.HSB),HSV:this.isModeEnabled(a.PaletteModes.HSV)};
}},_fixInRgbRange:function(d,c){if(c){d=Math.round(d);
}if(d<0){d=0;
}else{if(d>255){d=255;
}}return d;
},_addRgbVectors:function(d,c){return{r:this._fixInRgbRange(d.r+c.r),g:this._fixInRgbRange(d.g+c.g),b:this._fixInRgbRange(d.b+c.b)};
},_multiplyRgbVectorByNum:function(d,c){return{r:this._fixInRgbRange(c.r*d,true),g:this._fixInRgbRange(c.g*d,true),b:this._fixInRgbRange(c.b*d,true)};
},isModeEnabled:function(c){return c&this._paletteModes?true:false;
},_createTabStrip:function(){if(this._multiPage){return;
}var h=this.get_element();
var k=this.get_id();
var j=this._paletteWrapperElement=this._createDiv("rcpPalette",(k+"_palette"));
if(this._showIcon){if(!$telerik.isIE6){j.style.position="absolute";
}j.style.visibility="hidden";
}h.appendChild(j);
var n=this.isModeEnabled(a.PaletteModes.WebPalette);
var m=this.isModeEnabled(a.PaletteModes.RGBSliders);
var p=this.isModeEnabled(a.PaletteModes.HSB);
var o=this.isModeEnabled(a.PaletteModes.HSV);
var e=this.get_id();
var l=null;
if(n&&m||n&&p||n&&o||m&&p||m&&o||p&&o){var f=this._tabStrip=this._createDiv("rcpTabs");
j.appendChild(f);
l=this._createElement("ul");
f.appendChild(l);
}this._createHeader(j);
var i=this._multiPage=this._createElement("div",null,{className:"rcpViews"});
j.appendChild(i);
var q=e+"_webPalette";
var c="rcpPageView";
var d=true;
if(n){this._createTabWithContainer(d,c,i,"_webPalettePageView","_createPalette",this._localization[3],l,q);
d=false;
}if(m){q=e+"_rgbSliders";
this._createTabWithContainer(d,(c+" rcpRGBPageView"),i,"_rgbPageView","_createRgbSliders",this._localization[4],l,q);
d=false;
}if(p){q=e+"_millionColors";
var g=c+" rcpMillionColorsPageView rcpHsbPageView";
this._createTabWithContainer(d,g,i,"_millionColorsPageView","_createMillionColors",this._localization[5],l,q);
d=false;
}if(o){q=e+"_millionColors";
var g=c+" rcpMillionColorsPageView rcpHsvPageView";
this._createTabWithContainer(d,g,i,"_millionColorsPageView","_createMillionColors",this._localization[6],l,q);
}this._initializeColorElementsArray();
this._initializePalleteEventHandlers();
if(!this._popupBehavior){this._popupBehavior=$create(Telerik.Web.PopupBehavior,{id:k+"PopupBehavior",parentElement:this._iconWrapperElement,overlay:this._overlay,keepInScreenBounds:this._keepInScreenBounds},null,null,j);
}},_createTabWithContainer:function(e,c,f,j,i,d,k,l){if(k){var h=this._createTab(d,l);
k.appendChild(h);
}var g=this[j];
if(!g){g=this[j]=this._createDiv(c,l,null,(e?null:"none"));
f.appendChild(g);
}if(e){this._updateTabSelection(h,g);
this[i](g);
}},_createTab:function(e,d){var g=this._createElement("li");
var f=this._createA(e,null,d);
this._initializeTabHandler(f);
g.appendChild(f);
var c=this._createElement("span",e);
f.appendChild(c);
return g;
},_createEmptyColorElement:function(c){if(!this._showEmptyColor){return;
}var f=this._localization[2];
var e=this._emptyColorElement=this._createA(f,"rcpEmptyColor");
e.id=this.get_id()+"_emptycolor";
c.appendChild(e);
var d=this._createElement("span",f);
e.appendChild(d);
},_createPreviewElement:function(c){if(!this._previewColor){return;
}var d=this._selectedColor;
if(!d){d="white";
}var e=this._previewElement=this._createDiv("rcpColorPreview",(this.get_id()+"_preview"),d,null,"<!-- / -->");
c.appendChild(e);
this._createHexColorInput(c);
},_tabClicked:function(j){if(this._enabled){var g=(j.target||j.srcElement);
var k=this._getParentByTagName(g,"li");
var n=this._getParentByTagName(g,"a");
if(!n){return;
}var c=n.getAttribute("rel");
var f=$get(c);
if(!k||!f){return;
}var d=this._isModeSelected(a.PaletteModes.RGBSliders,f);
var l=this._isModeSelected(a.PaletteModes.HSB,f,k);
var m=l||this._isModeSelected(a.PaletteModes.HSV,f,k);
var i=0;
this._updateHeaderFooter(d||m);
this._updateTabSelection(k,f);
if(this._isModeSelected(a.PaletteModes.WebPalette,f)){this._createPalette(f);
hexStyle="readonly";
i=this._paletteSizes.webPalette;
}else{if(d){this._createRgbSliders(f);
i=this._paletteSizes.rgbSliders;
}else{if(m){this._createMillionColors(f);
i=this._paletteSizes.millionColors;
if(this._rightToLeft&&$telerik.isIE&&Sys.Browser.version<8&&document.forms&&document.forms.length>0){document.forms[0].style.cssText=document.forms[0].style.cssText;
}var o=this.get_millionColorsSlider();
l?o.set_dragText(this._localization[11]):o.set_dragText(this._localization[12]);
}}}var h=this._showIcon?this._paletteWrapperElement:this._wrapperElement;
if(h&&(parseInt(h.style.width)!=i)){h.style.width=(i-this.getElementBox(h).horizontal)+"px";
}this.set_selectedColor(this._selectedColor);
this._updateOverlaySize();
}return $telerik.cancelRawEvent(j);
},_updateTabSelection:function(g,d){if(g&&d){var c=this._isMillionColorsTabSelected(g);
if(c.HSB){Sys.UI.DomElement.removeCssClass(d,"rcpHsvPageView");
Sys.UI.DomElement.addCssClass(d,"rcpHsbPageView");
}else{if(c.HSV){Sys.UI.DomElement.removeCssClass(d,"rcpHsbPageView");
Sys.UI.DomElement.addCssClass(d,"rcpHsvPageView");
}}var e=this._selectedTab;
var f=this._selectedContainer;
if(e&&f){Sys.UI.DomElement.removeCssClass(e,"rcpSelectedTab");
f.style.display="none";
}Sys.UI.DomElement.addCssClass(g,"rcpSelectedTab");
d.style.display="";
}this._selectedTab=g;
this._selectedContainer=d;
},_updateHeaderFooter:function(e){var d=this._footer;
if(d){d.style.display=e?"":"none";
}var c=this._hexColorInput;
if(c){c.readOnly=e?"":"readonly";
}},_updateOverlaySize:function(){var c=this._paletteWrapperElement;
var d=c._hideWindowedElementsIFrame;
if(!d){return;
}$telerik.setSize(d,$telerik.getOuterSize(c));
},_initializeTabHandler:function(c){$addHandler(c,"click",Function.createDelegate(this,this._tabClicked));
},_initializeApplyHandler:function(c){$addHandler(c,"click",Function.createDelegate(this,this._applyClick));
},_initializeHexHandler:function(c){if(!this.isModeEnabled(a.PaletteModes.RGBSliders)&&!this.isModeEnabled(a.PaletteModes.HSB)&&!this.isModeEnabled(a.PaletteModes.HSV)){return;
}$addHandlers(c,{blur:this._hexColorChange},this);
},_initializeRgbInputHandler:function(c){$addHandlers(c,{blur:this._rgbInputValueChange},this);
},_initializeRgbSliderHandler:function(e){var f=this;
var d=function(g,h){f._rgbSliderValueChanged(g,h);
};
var c=function(g,h){f._eventStartedInControl=true;
};
e.add_valueChanged(d);
if(this._showIcon){e.add_slideStart(c);
}},_initializeMillionColorsRgbInputHandler:function(c){if(!c){return;
}$addHandlers(c,{blur:this._millionColorsRgbInputValueChange},this);
},_initializeMillionColorsInputHandler:function(c){if(!c){return;
}$addHandlers(c,{blur:this._millionColorsInputValueChange},this);
},_initializeMillionColorsSliderHandler:function(){var e=this.get_millionColorsSlider();
if(!e){return;
}var f=this;
var d=function(g,h){f._millionColorsSliderValueChanged(g,h);
};
var c=function(g,h){f._eventStartedInControl=true;
};
e.add_valueChanged(d);
if(this._showIcon){e.add_slideStart(c);
}},_initializeMillionColorsPaletteHandler:function(){var c=this._millionColorsPalette;
if(c){$addHandlers(c,{mousedown:this._onMillionColorsPaletteMouseDown},this);
}},_createElement:function(f,k,e,i){var h=document.createElement(f);
for(var c in e){var d=e[c];
if(d!=null&&d!=""){h[c]=d;
}}for(var j in i){var g=i[j];
if(g!=null&&g!=""){h.style[j]=g;
}}if(k){h.innerHTML=k;
}return h;
},_createA:function(d,e,f,c){return this._createElement("a",null,{className:e,href:"#",title:d,rel:f},{background:c});
},_createDiv:function(e,f,c,g,d){return this._createElement("div",d,{className:e,id:f},{background:c,display:g});
},_createInput:function(c,e,d){return this._createElement("input",null,{className:c,id:d,type:"text",value:e});
},getElementBox:function(d){var c={horizontal:0,vertical:0};
if(d){var e=$telerik.getBorderBox(d);
var f=$telerik.getPaddingBox(d);
c.horizontal=e.horizontal+f.horizontal;
c.vertical=e.vertical+f.vertical;
}return c;
},showPalette:function(){if(this._paletteDisplayed){return;
}this._createTabStrip();
var c=this._popupBehavior;
c.set_x(0);
c.set_y($telerik.getSize(this._iconWrapperElement).height);
c.show();
var d=this._applyButton;
if($telerik.isIE6&&d){d.style.visibility="visible";
setTimeout(Function.createDelegate(this,function(){d.style.visibility="";
}),0);
}this.set_selectedColor(this._selectedColor);
this._paletteDisplayed=true;
this.raiseEvent("popUpShow",Sys.EventArgs.Empty);
},hidePalette:function(){var c=this._popupBehavior;
if(c){c.hide();
}this._paletteDisplayed=false;
},getIconContainer:function(){return this._iconWrapperElement;
},getPaletteContainer:function(){return this._paletteWrapperElement;
},add_loaded:function(c){this.add_load(c);
},remove_loaded:function(c){this.remove_load(c);
},add_colorSelecting:function(c){this.add_colorPreview(c);
},remove_colorSelecting:function(c){this.remove_colorPreview(c);
},get_selectedColor:function(){return this._selectedColor;
},set_selectedColor:function(c,d){if(!c||(c.toString().toLowerCase()=="null")){c=null;
}var i=this._selectedColor;
if(!i){i=null;
}if(c!=null){c=c.toUpperCase();
}this._selectedColor=c;
this._previewCurrentColor(c);
if(this._showIcon){this._setIconColor(c);
}if(!d&&this._selectedContainer){if(this._isModeSelected(a.PaletteModes.WebPalette)){var h=this._emptyColorElement;
var f=this._getMarkedElement();
if(f!=null){if(f!=h){f.className="rcpColorBox";
}}f=this._getBoxElementByColor(c);
if(f!=null){this._setMarkedElement(f);
if(f!=h){f.className="rcpSelectedColor";
}}}else{var e=this._isModeSelected(a.PaletteModes.RGBSliders)?"_updateRgbSlidersUI":(this._isModeSelected(a.PaletteModes.HSB)?"_updateHslPaletteElementsUI":"_updateHsvPaletteElementsUI");
this._millionColorsSliderAvoidRecursion=true;
this[e](this._getRgbFromHex(c));
this._millionColorsSliderAvoidRecursion=false;
}}this.updateClientState();
if(this._selectedColor!=i){var g=new a.ColorPickerColorChangeEventArgs(i);
this.raiseEvent("colorChange",g);
if(this._autoPostBack){this._raiseColorChangedServerEvent();
}}},get_selectedColorTitle:function(){var c=this._getBoxElementByColor(this._selectedColor);
if(c!=null){return c.getAttribute("title");
}return this._selectedColor;
},get_enabled:function(){return this._enabled;
},set_enabled:function(f){if(this._enabled==f){return;
}this._enabled=f;
if(!this._wrapperElement){return;
}var j=[this.get_redSlider(),this.get_greenSlider(),this.get_blueSlider(),this.get_millionColorsSlider()];
for(var c=0,l=j.length;
c<l;
c++){var k=j[c];
if(k&&k.set_enabled){k.set_enabled(f);
}}var g=[this._hexColorInput,this._redInput,this._greenInput,this._blueInput];
var h=this._millionColorsInputs;
if(h){g=g.concat([h.r,h.g,h.b,h.h,h.s,h.l,h.v]);
}var e=this.get_element();
if(f){Sys.UI.DomElement.removeCssClass(e,"rcpDisabled");
e.removeAttribute("disabled");
for(var c=0,l=g.length;
c<l;
c++){var d=g[c];
if(d){d.removeAttribute("disabled");
}}}else{Sys.UI.DomElement.addCssClass(e,"rcpDisabled");
e.setAttribute("disabled","disabled");
for(var c=0,l=g.length;
c<l;
c++){var d=g[c];
if(d){d.setAttribute("disabled","disabled");
}}}},get_overlay:function(){return this._overlay;
},set_overlay:function(c){this._overlay=c;
var d=this._popupBehavior;
if(d){d.set_overlay(this._overlay);
if(this._showIcon&&this._paletteDisplayed){d.show();
}}},get_keepInScreenBounds:function(){return this._keepInScreenBounds;
},set_keepInScreenBounds:function(c){this._keepInScreenBounds=c;
var d=this._popupBehavior;
if(d){d.set_keepInScreenBounds(c);
if(this._showIcon&&this._paletteDisplayed){d.show();
}}},_initializeEventHandlers:function(){this._initializePalleteEventHandlers();
if(this._showIcon){$addHandlers(this._iconWrapperElement,{mousedown:this._onIconMouseDown,mouseup:this._onIconMouseUp,click:$telerik.cancelRawEvent},this);
$addHandlers(this.get_element(),{mousedown:this._onWrapperMouseDown},this);
this._mouseUpHandler=Function.createDelegate(this,this._onMouseUp);
$telerik.addExternalHandler(document,"mouseup",this._mouseUpHandler);
}},_initializePalleteEventHandlers:function(){var c=this._webPaletteWrapper;
if(c){$addHandlers(c,{mouseover:this._onBoxMouseOver,mouseup:this._onBoxClick,mouseout:this._onBoxMouseOut,click:$telerik.cancelRawEvent,selectstart:this._onSelectStart},this);
}var d=this._emptyColorElement;
if(d&&this._showEmptyColor){$addHandlers(d,{click:this._onEmptyColorClick},this);
}},_disposeHandlers:function(){var c=this._webPaletteWrapper;
if(c){$clearHandlers(c);
}var d=this._emptyColorElement;
if(d&&this._showEmptyColor){$clearHandlers(d);
}if(this._showIcon){$clearHandlers(this._iconWrapperElement);
$clearHandlers(this.get_element());
$telerik.removeExternalHandler(document,"mouseup",this._mouseUpHandler);
}this._mouseUpHandler=null;
},_raiseColorChangedServerEvent:function(){setTimeout(Function.createDelegate(this,function(){__doPostBack(this._uniqueID);
}),0);
},_onMouseUp:function(d){if(!this._enabled){return;
}if(this._eventStartedInControl){this._eventStartedInControl=false;
return;
}var c=d.target||d.srcElement;
if($telerik.isDescendantOrSelf(this._paletteWrapperElement,c)){return;
}this.hidePalette();
},_onBoxMouseOver:function(d){if(!this._enabled){return;
}var c=this._getColorBoxElement(d.target);
if(c==null){return;
}var f=this._getElementColor(c);
this._previewCurrentColor(f,true,c.title);
},_onBoxMouseOut:function(c){if($telerik.isMouseOverElementEx(this._webPaletteWrapper,c)){return;
}this._previewCurrentColor(this.get_selectedColor());
},_applyClick:function(h){if(this._enabled){var c;
var f=this._hexColorInput;
if(f){c=f.value;
}else{var g;
if(this._isModeSelected(a.PaletteModes.RGBSliders)){g={r:this.get_redSlider().get_value(),g:this.get_greenSlider().get_value(),b:this.get_blueSlider().get_value()};
}else{var d=this._millionColorsInputs;
g={r:parseInt(d.r.value),g:parseInt(d.g.value),b:parseInt(d.b.value)};
}c=this._rgbValuesToHex(g.r,g.g,g.b);
}this._applyColorAndClose(c,true);
}return $telerik.cancelRawEvent(h);
},_onEmptyColorClick:function(c){if(this._enabled){this._applyColorAndClose(null);
}return $telerik.cancelRawEvent(c);
},_applyColorAndClose:function(e,c){var d=this._showIcon;
this.set_selectedColor(e,(d||c));
if(d){this.hidePalette();
}},_onWrapperMouseDown:function(c){if(!this._enabled){return;
}this._eventStartedInControl=true;
},_onIconMouseDown:function(c){return $telerik.cancelRawEvent(c);
},_onIconMouseUp:function(c){if(this._enabled){if(this._paletteDisplayed){this.hidePalette();
}else{this.showPalette();
}}return $telerik.cancelRawEvent(c);
},_getElementColor:function(c){if(c==this._emptyColorElement){return null;
}return c.firstChild.innerHTML;
},_setIconColor:function(d){var c=(d)?d:this._localization[13];
var e=this._localization[0]+" "+this._localization[1].toString().replace("{0}",c);
this._iconWrapperElement.title=e;
this._iconElement.style.backgroundColor=(d)?d:"#FFFFFF";
},_onSelectStart:function(c){return $telerik.cancelRawEvent(c);
},_onBoxClick:function(c){if(this._enabled){this._eventStartedInControl=false;
if(c.button!=0){return;
}var d=this._getColorBoxElement(c.target);
if(d==null){return;
}this._applyColorAndClose(this._getElementColor(d));
}return $telerik.cancelRawEvent(c);
},_getMarkedElement:function(){var f=this._markedElement;
if(f){return f;
}var e=this._webPaletteWrapper;
if(!e){return null;
}var c=e.getElementsByTagName("A");
for(var g=0,h=c.length;
g<h;
g++){var d=c[g];
if(d.className=="rcpSelectedColor"){return d;
}}return null;
},_setMarkedElement:function(c){this._markedElement=c;
},_getColorBoxElement:function(e){var d=3;
var c=0;
while(c<d){if(e.className=="rcpColorBox"||e.className=="rcpSelectedColor"||e.className.indexOf("rcpEmptyColor")>-1){return e;
}c++;
e=e.parentNode;
}return null;
},_getParentByTagName:function(f,c){var e=3;
var d=0;
while(d<e){if(f.tagName.toLowerCase()==c){return f;
}d++;
f=f.parentNode;
}return null;
},_getBoxElementByColor:function(c){if(!c){return this._emptyColorElement;
}c=c.toUpperCase();
return this._elementsByColor[c];
},_previewCurrentColor:function(h,f,d){if(!this.get_isInitialized()){return;
}if(f&&(h!=this._lastPreviewColor)){var c=new a.ColorPickerColorPreviewEventArgs(h);
this.raiseEvent("colorPreview",c);
}this._lastPreviewColor=h;
if(!this._previewColor){return;
}if(h==null){h="#FFFFFF";
d=this._localization[2];
}h=h.toUpperCase();
if(!d){d=h;
}var g=this._previewElement;
if(g){g.style.backgroundColor=h;
}var e=this._hexColorInput;
if(e){e.value=h;
}},saveClientState:function(){var e=["selectedColor"];
var c={};
for(var d=0;
d<e.length;
d++){c[e[d]]=this["get_"+e[d]]();
}return Sys.Serialization.JavaScriptSerializer.serialize(c);
}};
b.registerControlProperties(a.RadColorPicker,{paletteModes:a.PaletteModes.WebPalette,hiddenSlider:null,redSlider:null,greenSlider:null,blueSlider:null,millionColorsSlider:null});
b.registerControlEvents(a.RadColorPicker,["load","colorPreview","colorChange","popUpShow"]);
a.RadColorPicker.registerClass("Telerik.Web.UI.RadColorPicker",a.RadWebControl);
})();
